<template>
  <view class="container">
    <!-- 标题栏 -->
    <!-- <view class="navbar">
      <text class="back" @click="goBack">&#60;</text>
      <text class="title">退货商品</text>
      <text class="help">&#128712;</text>
    </view> -->

    <!-- 状态和时间 -->
    <view class="status-row">
      <view class="time">{{ timeText }}</view>
    </view>

    <view class="status-row">
      <view class="time">{{ statusText }}</view>
    </view>

    <!-- 商品卡片 -->
    <view class="card">
      <view v-for="(item, idx) in returnList" :key="item.id || idx" class="item-row">
        <image :src="item.image" class="product-img" />
        <view class="info">
          <text class="name">{{ item.productName }}</text>
          <text class="spec">{{ item.sku }}</text>
          <text class="price">￥{{ item.price }}</text>
        </view>
        <text class="count">x{{ item.count || item.number || 1 }}</text>
      </view>
    </view>
  </view>
</template>

<script>
export default {
  data() {
    return {
      returnList: [],
      inOrOutWarehouseStatus: 0,
      timeText: "",
    };
  },
  computed: {
    statusText() {
      if (this.inOrOutWarehouseStatus == 0) return "待入库";
      if (this.inOrOutWarehouseStatus == 1) return "已入库";
      if (this.inOrOutWarehouseStatus == 2) return "已取消";
      return "";
    }
  },
  onLoad(options) {
    if (options.returnList) {
      this.returnList = JSON.parse(decodeURIComponent(options.returnList));
    }
    if (options.inOrOutWarehouseStatus!='undefined') {
      this.inOrOutWarehouseStatus = options.inOrOutWarehouseStatus;
      console.log(this.inOrOutWarehouseStatus);
    }
    if (this.returnList.length && this.returnList[0].createTime) {
      this.timeText = this.returnList[0].createTime;
    } else {
      this.timeText = "";
    }
  },
  methods: {
    goBack() {
      uni.navigateBack();
    }
  }
};
</script>

<style scoped>
.container {
  min-height: 100vh;
  background: #f5f6fa; /* 更淡的灰色背景 */
}
.navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #0066e6;
  color: #fff;
  height: 90rpx;
  padding: 0 30rpx;
}
.title {
  font-size: 36rpx;
  font-weight: bold;
}
.back, .help {
  font-size: 32rpx;
}
.status-row {
  margin: 30rpx 30rpx 0 30rpx;
  display: inline-flex;
  flex-direction: column;
  background: #eaf3ff;
  border-radius: 12rpx;
  padding: 16rpx 24rpx;
  box-shadow: 0 2rpx 8rpx #e0e3ea;
  min-width: 220rpx;
}

.status-row .status {
  color: #0066e6;
  font-size: 32rpx;
  font-weight: bold;
  margin-bottom: 6rpx;
}

.status-row .time {
  color: #888;
  font-size: 24rpx;
  margin-top: 2rpx;
  font-weight: normal;
}
.card {
  background: #fff;
  border-radius: 20rpx;
  margin: 20rpx 30rpx 0 30rpx; /* 顶部间距减少，避免与status-row重叠 */
  box-shadow: 0 8rpx 24rpx #e0e3ea;
  padding: 30rpx 0;
  border: 1rpx solid #e6e6e6;
}
.item-row {
  display: flex;
  align-items: center;
  padding: 20rpx 30rpx;
  border-bottom: 1rpx solid #f0f0f0;
}
.item-row:last-child {
  border-bottom: none;
}
.product-img {
  width: 100rpx;
  height: 100rpx;
  border-radius: 10rpx;
  background: #eee;
  box-shadow: 0 2rpx 8rpx #d0d0d0;
  border: 1rpx solid #e0e0e0;
}
.info {
  flex: 1;
  margin-left: 20rpx;
  display: flex;
  flex-direction: column;
  background: #f8fafd;
  border-radius: 8rpx;
  padding: 10rpx 16rpx;
}
.name {
  font-size: 30rpx;
  font-weight: bold;
}
.spec {
  color: #888;
  font-size: 24rpx;
  margin-top: 6rpx;
}
.price {
  color: #e60012;
  font-size: 28rpx;
  margin-top: 6rpx;
}
.count {
  font-size: 28rpx;
  color: #888;
  margin-left: 20rpx;
}
</style>
